﻿namespace Cmn.Cls
{
    using System;
    using System.Runtime.InteropServices;
    using System.Text;

    public class iniFile
    {
        private string path;

        public iniFile(string iniPath)
        {
            this.path = iniPath;
        }

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
        public string ReadValue(string section, string key)
        {
            StringBuilder retVal = new StringBuilder(0xff);
            int num = GetPrivateProfileString(section, key, "", retVal, 0xff, this.path);
            return retVal.ToString();
        }

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        public void WriteValue(string section, string key, string value)
        {
            WritePrivateProfileString(section, key, value, this.path);
        }
    }
}

